home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Alles Voor Internet / Tout Pour Internet
/
alles voor internet.iso
/
MacInternet™
/
Telnet
/
NCSA
/
tn3270 2.4d7 source
/
tn3270
/
sppc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-05-28
|
4KB
|
183 lines
#include <Devices.h>
#include <Files.h>
#include <String.h>
#include "sppcinterface.h"
static short sppcrefnum = 0; /* driver reference number */
OSErr getsppcref(void); /* routine to get driver number */
OSErr SPPCRegister(unsigned char *myName, short *myRefNum)
{
OSErr rc;
ParamBlockRec pbr;
parmrec pmr, *pmrptr;
/* initialize for all calls */
rc = getsppcref();
if (rc != noErr) return(rc);
memset(&pbr, 0, sizeof(ParamBlockRec));
pbr.cntrlParam.ioCRefNum = sppcrefnum;
pmrptr = &pmr;
memcpy(pbr.cntrlParam.csParam, &pmrptr, 4);
memset (&pmr, 0, sizeof(parmrec));
/* definitions for this call */
pbr.cntrlParam.csCode = 1;
pmr.name = myName;
pmr.refptr = myRefNum;
return(PBControl(&pbr, 0));
}
OSErr SPPCDeRegister(short myRefNum)
{
OSErr rc;
ParamBlockRec pbr;
parmrec pmr, *pmrptr;
/* initialize for all calls */
rc = getsppcref();
if (rc != noErr) return(rc);
memset(&pbr, 0, sizeof(ParamBlockRec));
pbr.cntrlParam.ioCRefNum = sppcrefnum;
pmrptr = &pmr;
memcpy(pbr.cntrlParam.csParam, &pmrptr, 4);
memset (&pmr, 0, sizeof(parmrec));
/* definitions for this call */
pbr.cntrlParam.csCode = 2;
pmr.refnum = myRefNum;
return(PBControl(&pbr, 0));
}
OSErr SPPCLookup(unsigned char *appName, short *itsRefNum)
{
OSErr rc;
ParamBlockRec pbr;
parmrec pmr, *pmrptr;
/* initialize for all calls */
rc = getsppcref();
if (rc != noErr) return(rc);
memset(&pbr, 0, sizeof(ParamBlockRec));
pbr.cntrlParam.ioCRefNum = sppcrefnum;
pmrptr = &pmr;
memcpy(pbr.cntrlParam.csParam, &pmrptr, 4);
memset (&pmr, 0, sizeof(parmrec));
/* definitions for this call */
pbr.cntrlParam.csCode = 3;
pmr.name = appName;
pmr.refptr = itsRefNum;
return(PBControl(&pbr, 0));
}
OSErr SPPCSend(short myRefNum, short toRefNum,
unsigned long replyId, Handle theMessage,
unsigned short msgLength, unsigned long *msgId)
{
OSErr rc;
ParamBlockRec pbr;
parmrec pmr, *pmrptr;
/* initialize for all calls */
rc = getsppcref();
if (rc != noErr) return(rc);
memset(&pbr, 0, sizeof(ParamBlockRec));
pbr.cntrlParam.ioCRefNum = sppcrefnum;
pmrptr = &pmr;
memcpy(pbr.cntrlParam.csParam, &pmrptr, 4);
memset (&pmr, 0, sizeof(parmrec));
/* definitions for this call */
pbr.cntrlParam.csCode = 4;
pmr.refnum = myRefNum;
pmr.refnum2 = toRefNum;
pmr.replyid = replyId;
pmr.msg = theMessage;
pmr.msglen = msgLength;
pmr.msgid = msgId;
return(PBControl(&pbr, 0));
}
OSErr SPPCGet(short myRefNum, short *fromRefNum,
unsigned long replyId, Handle theMessage,
unsigned short *msgLength, unsigned long *msgId,
unsigned long *replyIdPtr)
{
OSErr rc;
ParamBlockRec pbr;
parmrec pmr, *pmrptr;
/* initialize for all calls */
rc = getsppcref();
if (rc != noErr) return(rc);
memset(&pbr, 0, sizeof(ParamBlockRec));
pbr.cntrlParam.ioCRefNum = sppcrefnum;
pmrptr = &pmr;
memcpy(pbr.cntrlParam.csParam, &pmrptr, 4);
memset (&pmr, 0, sizeof(parmrec));
/* definitions for this call */
pbr.cntrlParam.csCode = 5;
pmr.refnum = myRefNum;
pmr.refptr = fromRefNum;
pmr.replyid = replyId;
pmr.msg = theMessage;
pmr.msglenptr = msgLength;
pmr.msgid = msgId;
pmr.replyidptr = replyIdPtr;
return(PBControl(&pbr, 0));
}
OSErr SPPCClear(short myRefNum)
{
OSErr rc;
ParamBlockRec pbr;
parmrec pmr, *pmrptr;
/* initialize for all calls */
rc = getsppcref();
if (rc != noErr) return(rc);
memset(&pbr, 0, sizeof(ParamBlockRec));
pbr.cntrlParam.ioCRefNum = sppcrefnum;
pmrptr = &pmr;
memcpy(pbr.cntrlParam.csParam, &pmrptr, 4);
memset (&pmr, 0, sizeof(parmrec));
/* definitions for this call */
pbr.cntrlParam.csCode = 6;
pmr.refnum = myRefNum;
return(PBControl(&pbr, 0));
}
OSErr SPPCDeleteMsg(unsigned long *msgId)
{
OSErr rc;
ParamBlockRec pbr;
parmrec pmr, *pmrptr;
/* initialize for all calls */
rc = getsppcref();
if (rc != noErr) return(rc);
memset(&pbr, 0, sizeof(ParamBlockRec));
pbr.cntrlParam.ioCRefNum = sppcrefnum;
pmrptr = &pmr;
memcpy(pbr.cntrlParam.csParam, &pmrptr, 4);
memset (&pmr, 0, sizeof(parmrec));
/* definitions for this call */
pbr.cntrlParam.csCode = 7;
pmr.msgid = msgId;
return(PBControl(&pbr, 0));
}
OSErr getsppcref(void)
{
ParamBlockRec pbr;
OSErr rc;
if (sppcrefnum != 0) return(noErr);
memset(&pbr, 0, sizeof(ParamBlockRec));
pbr.ioParam.ioNamePtr = "\p.SPPC";
rc = PBOpen(&pbr, 0);
if (rc == noErr) {
sppcrefnum = pbr.ioParam.ioRefNum;
}
return(rc);
}